* things go faster. */
#define GTK_STYLE_CONTEXT_CACHED_CHANGE (GTK_CSS_CHANGE_STATE)
-typedef struct GtkStyleInfo GtkStyleInfo;
+typedef struct GtkCssNode GtkCssNode;
typedef struct PropertyValue PropertyValue;
struct PropertyValue
GValue value;
};
-struct GtkStyleInfo
+struct GtkCssNode
{
GtkCssNodeDeclaration *decl;
- GtkStyleInfo *parent;
+ GtkCssNode *parent;
GtkCssStyle *values;
};
GtkWidget *widget;
GtkWidgetPath *widget_path;
GHashTable *style_values;
- GtkStyleInfo *info;
+ GtkCssNode *cssnode;
GSList *saved_nodes;
GArray *property_cache;
gint scale;
g_array_set_size (priv->property_cache, 0);
}
-static GtkStyleInfo *
-style_info_new (void)
+static GtkCssNode *
+gtk_css_node_new (void)
{
- GtkStyleInfo *info;
+ GtkCssNode *cssnode;
- info = g_slice_new0 (GtkStyleInfo);
- info->decl = gtk_css_node_declaration_new ();
+ cssnode = g_slice_new0 (GtkCssNode);
+ cssnode->decl = gtk_css_node_declaration_new ();
- return info;
+ return cssnode;
}
static void
-style_info_set_values (GtkStyleInfo *info,
- GtkCssStyle *values)
+gtk_css_node_set_values (GtkCssNode *cssnode,
+ GtkCssStyle *values)
{
- if (info->values == values)
+ if (cssnode->values == values)
return;
if (values)
g_object_ref (values);
- if (info->values)
- g_object_unref (info->values);
+ if (cssnode->values)
+ g_object_unref (cssnode->values);
- info->values = values;
+ cssnode->values = values;
}
static void
-style_info_free (GtkStyleInfo *info)
+gtk_css_node_free (GtkCssNode *cssnode)
{
- if (info->values)
- g_object_unref (info->values);
- gtk_css_node_declaration_unref (info->decl);
- g_slice_free (GtkStyleInfo, info);
+ if (cssnode->values)
+ g_object_unref (cssnode->values);
+ gtk_css_node_declaration_unref (cssnode->decl);
+ g_slice_free (GtkCssNode, cssnode);
}
static GtkCssStyle *
-style_info_get_parent_style (GtkStyleContext *context,
- GtkStyleInfo *info)
+gtk_css_node_get_parent_style (GtkStyleContext *context,
+ GtkCssNode *cssnode)
{
GtkStyleContextPrivate *priv;
- g_assert (info->parent == NULL || info->parent->values != NULL);
+ g_assert (cssnode->parent == NULL || cssnode->parent->values != NULL);
- if (info->parent)
- return info->parent->values;
+ if (cssnode->parent)
+ return cssnode->parent->values;
priv = context->priv;
}
static void
-gtk_style_context_pop_style_info (GtkStyleContext *context)
+gtk_style_context_pop_style_node (GtkStyleContext *context)
{
GtkStyleContextPrivate *priv = context->priv;
g_return_if_fail (priv->saved_nodes != NULL);
- style_info_free (priv->info);
- priv->info = priv->saved_nodes->data;
- priv->saved_nodes = g_slist_remove (priv->saved_nodes, priv->info);
+ gtk_css_node_free (priv->cssnode);
+ priv->cssnode = priv->saved_nodes->data;
+ priv->saved_nodes = g_slist_remove (priv->saved_nodes, priv->cssnode);
}
static void
priv->screen = gdk_screen_get_default ();
/* Create default info store */
- priv->info = style_info_new ();
- gtk_css_node_declaration_set_state (&priv->info->decl, GTK_STATE_FLAG_DIR_LTR);
- priv->info->values = g_object_ref (gtk_css_static_style_get_default (priv->screen));
+ priv->cssnode = gtk_css_node_new ();
+ gtk_css_node_declaration_set_state (&priv->cssnode->decl, GTK_STATE_FLAG_DIR_LTR);
+ priv->cssnode->values = g_object_ref (gtk_css_static_style_get_default (priv->screen));
priv->property_cache = g_array_new (FALSE, FALSE, sizeof (PropertyValue));
g_hash_table_destroy (priv->style_values);
while (priv->saved_nodes)
- gtk_style_context_pop_style_info (style_context);
- style_info_free (priv->info);
+ gtk_style_context_pop_style_node (style_context);
+ gtk_css_node_free (priv->cssnode);
gtk_style_context_clear_property_cache (style_context);
g_array_free (priv->property_cache, TRUE);
return context->priv->saved_nodes != NULL;
}
-static GtkStyleInfo *
+static GtkCssNode *
gtk_style_context_get_root (GtkStyleContext *context)
{
GtkStyleContextPrivate *priv;
if (priv->saved_nodes != NULL)
return g_slist_last (priv->saved_nodes)->data;
else
- return priv->info;
+ return priv->cssnode;
}
static GtkWidgetPath *
length = gtk_widget_path_length (path);
if (gtk_style_context_is_saved (context))
{
- GtkStyleInfo *root = gtk_style_context_get_root (context);
+ GtkCssNode *root = gtk_style_context_get_root (context);
if (length > 0)
gtk_css_node_declaration_add_to_widget_path (root->decl, path, length - 1);
{
GtkStyleContextPrivate *priv;
GtkCssStyle *values;
- GtkStyleInfo *info;
+ GtkCssNode *cssnode;
priv = context->priv;
- info = priv->info;
+ cssnode = priv->cssnode;
/* Current data in use is cached, just return it */
- if (info->values)
- return info->values;
+ if (cssnode->values)
+ return cssnode->values;
g_assert (priv->widget != NULL || priv->widget_path != NULL);
g_assert (gtk_style_context_is_saved (context));
- values = g_hash_table_lookup (priv->style_values, info->decl);
+ values = g_hash_table_lookup (priv->style_values, cssnode->decl);
if (values)
{
- style_info_set_values (info, values);
+ gtk_css_node_set_values (cssnode, values);
return values;
}
- values = build_properties (context, info->decl, style_info_get_parent_style (context, info));
+ values = build_properties (context, cssnode->decl, gtk_css_node_get_parent_style (context, cssnode));
g_hash_table_insert (priv->style_values,
- gtk_css_node_declaration_ref (info->decl),
+ gtk_css_node_declaration_ref (cssnode->decl),
g_object_ref (values));
- style_info_set_values (info, values);
+ gtk_css_node_set_values (cssnode, values);
g_object_unref (values);
return values;
GtkCssNodeDeclaration *decl;
GtkCssStyle *values;
- if (gtk_css_node_declaration_get_state (context->priv->info->decl) == state)
+ if (gtk_css_node_declaration_get_state (context->priv->cssnode->decl) == state)
return g_object_ref (style_values_lookup (context));
if (g_getenv ("GTK_STYLE_CONTEXT_WARNING"))
g_warning ("State does not match current state");
- decl = gtk_css_node_declaration_ref (context->priv->info->decl);
+ decl = gtk_css_node_declaration_ref (context->priv->cssnode->decl);
gtk_css_node_declaration_set_state (&decl, state);
- values = build_properties (context, decl, style_info_get_parent_style (context, context->priv->info));
+ values = build_properties (context, decl, gtk_css_node_get_parent_style (context, context->priv->cssnode));
gtk_css_node_declaration_unref (decl);
return values;
GtkCssChange change)
{
GtkStyleContextPrivate *priv = context->priv;
- GtkStyleInfo *info = priv->info;
+ GtkCssNode *cssnode = priv->cssnode;
if (gtk_style_context_is_saved (context))
{
- style_info_set_values (info, NULL);
+ gtk_css_node_set_values (cssnode, NULL);
}
else
{
context->priv->widget = widget;
if (widget)
- gtk_css_node_declaration_set_type (&context->priv->info->decl, G_OBJECT_TYPE (widget));
+ gtk_css_node_declaration_set_type (&context->priv->cssnode->decl, G_OBJECT_TYPE (widget));
else
- gtk_css_node_declaration_set_type (&context->priv->info->decl, G_TYPE_NONE);
+ gtk_css_node_declaration_set_type (&context->priv->cssnode->decl, G_TYPE_NONE);
_gtk_style_context_update_animating (context);
GtkStateFlags old_flags;
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
- old_flags = gtk_css_node_declaration_get_state (context->priv->info->decl);
+ old_flags = gtk_css_node_declaration_get_state (context->priv->cssnode->decl);
- if (!gtk_css_node_declaration_set_state (&context->priv->info->decl, flags))
+ if (!gtk_css_node_declaration_set_state (&context->priv->cssnode->decl, flags))
return;
if (((old_flags ^ flags) & (GTK_STATE_FLAG_DIR_LTR | GTK_STATE_FLAG_DIR_RTL)) &&
{
g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), 0);
- return gtk_css_node_declaration_get_state (context->priv->info->decl);
+ return gtk_css_node_declaration_get_state (context->priv->cssnode->decl);
}
/**
{
gtk_widget_path_free (priv->widget_path);
priv->widget_path = NULL;
- gtk_css_node_declaration_set_type (&context->priv->info->decl, G_TYPE_NONE);
+ gtk_css_node_declaration_set_type (&context->priv->cssnode->decl, G_TYPE_NONE);
}
if (path)
{
priv->widget_path = gtk_widget_path_copy (path);
if (gtk_widget_path_length (path))
- gtk_css_node_declaration_set_type (&context->priv->info->decl,
+ gtk_css_node_declaration_set_type (&context->priv->cssnode->decl,
gtk_widget_path_iter_get_object_type (path, -1));
}
gtk_style_context_save (GtkStyleContext *context)
{
GtkStyleContextPrivate *priv;
- GtkStyleInfo *info;
+ GtkCssNode *cssnode;
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
if (!gtk_style_context_is_saved (context))
style_values_lookup (context);
- info = style_info_new ();
- info->decl = gtk_css_node_declaration_ref (priv->info->decl);
- info->parent = gtk_style_context_get_root (context);
+ cssnode = gtk_css_node_new ();
+ cssnode->decl = gtk_css_node_declaration_ref (priv->cssnode->decl);
+ cssnode->parent = gtk_style_context_get_root (context);
- priv->saved_nodes = g_slist_prepend (priv->saved_nodes, priv->info);
- priv->info = info;
+ priv->saved_nodes = g_slist_prepend (priv->saved_nodes, priv->cssnode);
+ priv->cssnode = cssnode;
}
/**
return;
}
- gtk_style_context_pop_style_info (context);
+ gtk_style_context_pop_style_node (context);
}
/**
priv = context->priv;
class_quark = g_quark_from_string (class_name);
- if (gtk_css_node_declaration_add_class (&priv->info->decl, class_quark))
+ if (gtk_css_node_declaration_add_class (&priv->cssnode->decl, class_quark))
gtk_style_context_queue_invalidate_internal (context, GTK_CSS_CHANGE_CLASS);
}
priv = context->priv;
- if (gtk_css_node_declaration_remove_class (&priv->info->decl, class_quark))
+ if (gtk_css_node_declaration_remove_class (&priv->cssnode->decl, class_quark))
gtk_style_context_queue_invalidate_internal (context, GTK_CSS_CHANGE_CLASS);
}
priv = context->priv;
- return gtk_css_node_declaration_has_class (priv->info->decl, class_quark);
+ return gtk_css_node_declaration_has_class (priv->cssnode->decl, class_quark);
}
static void
priv = context->priv;
- classes = gtk_css_node_declaration_list_classes (priv->info->decl);
+ classes = gtk_css_node_declaration_list_classes (priv->cssnode->decl);
quarks_to_strings (classes);
return classes;
priv = context->priv;
- regions = gtk_css_node_declaration_list_regions (priv->info->decl);
+ regions = gtk_css_node_declaration_list_regions (priv->cssnode->decl);
quarks_to_strings (regions);
return regions;
priv = context->priv;
region_quark = g_quark_from_string (region_name);
- if (gtk_css_node_declaration_add_region (&priv->info->decl, region_quark, flags))
+ if (gtk_css_node_declaration_add_region (&priv->cssnode->decl, region_quark, flags))
gtk_style_context_queue_invalidate_internal (context, GTK_CSS_CHANGE_REGION);
}
priv = context->priv;
- if (gtk_css_node_declaration_remove_region (&priv->info->decl, region_quark))
+ if (gtk_css_node_declaration_remove_region (&priv->cssnode->decl, region_quark))
gtk_style_context_queue_invalidate_internal (context, GTK_CSS_CHANGE_REGION);
}
priv = context->priv;
- return gtk_css_node_declaration_has_region (priv->info->decl, region_quark, flags_return);
+ return gtk_css_node_declaration_has_region (priv->cssnode->decl, region_quark, flags_return);
}
static gint
{
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
- gtk_css_node_declaration_set_junction_sides (&context->priv->info->decl, sides);
+ gtk_css_node_declaration_set_junction_sides (&context->priv->cssnode->decl, sides);
}
/**
{
g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), 0);
- return gtk_css_node_declaration_get_junction_sides (context->priv->info->decl);
+ return gtk_css_node_declaration_get_junction_sides (context->priv->cssnode->decl);
}
gboolean
for (l = priv->saved_nodes; l; l = l->next)
{
- style_info_set_values (l->data, NULL);
+ gtk_css_node_set_values (l->data, NULL);
}
g_hash_table_remove_all (priv->style_values);
const GtkBitmask *parent_changes)
{
GtkStyleContextPrivate *priv;
- GtkStyleInfo *info;
+ GtkCssNode *cssnode;
GtkCssStyle *current;
GtkBitmask *changes;
GSList *list;
priv->pending_changes = 0;
gtk_style_context_set_invalid (context, FALSE);
- info = priv->info;
- current = g_object_ref (info->values);
+ cssnode = priv->cssnode;
+ current = g_object_ref (cssnode->values);
/* Try to avoid invalidating if we can */
if (gtk_style_context_style_needs_full_revalidate (current, change))
{
GtkCssStyle *style, *static_style;
- static_style = build_properties (context, info->decl, style_info_get_parent_style (context, info));
+ static_style = build_properties (context, cssnode->decl, gtk_css_node_get_parent_style (context, cssnode));
style = gtk_css_animated_style_new (static_style,
priv->parent ? style_values_lookup (priv->parent) : NULL,
timestamp,
priv->scale,
gtk_style_context_should_create_transitions (context) ? current : NULL);
- style_info_set_values (info, style);
+ gtk_css_node_set_values (cssnode, style);
g_object_unref (static_style);
g_object_unref (style);
new_base = update_properties (context,
GTK_CSS_ANIMATED_STYLE (current)->style,
- info->decl,
- style_info_get_parent_style (context, info),
+ cssnode->decl,
+ gtk_css_node_get_parent_style (context, cssnode),
parent_changes);
new_values = gtk_css_animated_style_new_advance (GTK_CSS_ANIMATED_STYLE (current),
new_base,
{
new_values = update_properties (context,
current,
- info->decl,
- style_info_get_parent_style (context, info),
+ cssnode->decl,
+ gtk_css_node_get_parent_style (context, cssnode),
parent_changes);
}
- style_info_set_values (info, new_values);
+ gtk_css_node_set_values (cssnode, new_values);
g_object_unref (new_values);
}
else if (change & GTK_CSS_CHANGE_ANIMATE &&
{
GtkCssStyle *new_values;
- new_values = gtk_css_animated_style_new_advance (GTK_CSS_ANIMATED_STYLE (info->values),
- GTK_CSS_ANIMATED_STYLE (info->values)->style,
+ new_values = gtk_css_animated_style_new_advance (GTK_CSS_ANIMATED_STYLE (cssnode->values),
+ GTK_CSS_ANIMATED_STYLE (cssnode->values)->style,
timestamp);
- style_info_set_values (info, new_values);
+ gtk_css_node_set_values (cssnode, new_values);
g_object_unref (new_values);
}
}
_gtk_style_context_update_animating (context);
- changes = gtk_css_style_get_difference (info->values, current);
+ changes = gtk_css_style_get_difference (cssnode->values, current);
g_object_unref (current);
if (!_gtk_bitmask_is_empty (changes))
/* insta-recalculate the new style here */
style = build_properties (context,
- context->priv->info->decl,
- style_info_get_parent_style (context, context->priv->info));
- style_info_set_values (context->priv->info, style);
+ context->priv->cssnode->decl,
+ gtk_css_node_get_parent_style (context, context->priv->cssnode));
+ gtk_css_node_set_values (context->priv->cssnode, style);
g_object_unref (style);
changes = _gtk_bitmask_new ();